from sqlalchemy import Column, Integer, String, DateTime
from sqlalchemy.sql import func
from ..database import Base

class User(Base):
    __tablename__ = 'users'

    id = Column(String, primary_key=True, index=True)
    name = Column(String)  # 添加name字段
    email = Column(String, unique=True, index=True)
    password = Column(String)
    created_at = Column(DateTime(timezone=True), server_default=func.now())
    # 修改updated_at字段，添加server_default以确保创建时也有值
    updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())